<?php
// 本类由系统自动生成，仅供测试用途
class LoginAction extends Action {
    public function __construct() {
        parent::__construct();
        if(isset($_SESSION['admin_id'])&&$_SESSION['admin_id']>0){
            $this->redirect("/admin/index/index/",array(),0,'');
        }
    }

    //后台登入模块
    public function login(){
        $this->display();
    }
    //登入验证模块
    public function dologin(){
        if(isset($_POST['admin_name']) &&$_POST['admin_name']!=''
                &&isset($_POST['admin_password']) &&$_POST['admin_password']!=''
                &&isset($_POST['code']) &&$_POST['code']!=''){
            if($_POST['code']==$_SESSION['checkCode']){
                $where=array(
                    "admin_name"=>$_POST['admin_name'],
                    "admin_password"=>md5($_POST['admin_password']),
                );
                $admin=D("admin")->where($where)->find();
                if($admin){
                    $_SESSION['admin_id']=$admin['admin_id'];
                    $this->assign("jumpUrl",U("admin/index/index"));
                    $this->success("登陆成功");
                }
                
            }else{
                //print_r($_SESSION);
                $this->error("验证码错误");
            }
            
            
        }else{
            $this->error("数据不全");
        }
        
        
    }
    
}